#!/bin/bash
# 检查数据库是否已初始化

echo "检查数据库初始化状态..."
echo ""

# 尝试连接数据库（需要密码）
mysql -u root -p -e "USE ygswglxt; SHOW TABLES;" 2>/dev/null

if [ $? -eq 0 ]; then
    echo ""
    echo "✅ 数据库已初始化"
    TABLE_COUNT=$(mysql -u root -p -e "USE ygswglxt; SHOW TABLES;" 2>/dev/null | wc -l)
    echo "表数量: $((TABLE_COUNT - 1))"
    echo ""
    echo "测试用户:"
    mysql -u root -p -e "USE ygswglxt; SELECT username, name, role FROM sys_user;" 2>/dev/null
else
    echo ""
    echo "❌ 数据库未初始化或连接失败"
    echo "请执行: mysql -u root -p < sql/init.sql"
fi

